<template>
	<view class="page">
		<u-image show-loading :src="$imageOss(detail.image)" width="100%" height="248px" @click="preImage" />
		<view class="body">
			<Sub-title :label="detail.title" />
			<u-text :text="detail.address" lines="1" line-height="50rpx" color="#909090" size="28rpx"
				@click="Jump(`/pages/home/company?id=${detail.admin_id}`)" />
			<view class="base">
				<view class="box">
					<view class="">
						<u-text :text="`时间：${detail.start_time}—${detail.end_time}`" lines="1" line-height="48rpx"
							color="#909090" size="26rpx" />
					</view>
				</view>
				<view class="box">
					<u-text :text="`固定电话：${detail.telphone|| ''}`" lines="1" line-height="48rpx" color="#909090"
						size="26rpx" @click="callPhone" />
					<view class="" style="width: 40%;">
						<u-text :text="`联系人：${detail.contacts}`" lines="1" line-height="48rpx" color="#909090"
							size="26rpx" />
					</view>
				</view>
				<u-text :text="`发布来源：${detail.from || ''}`" lines="1" line-height="48rpx" color="#909090"
					size="26rpx" />
			</view>

			<view class="" style="display: flex;align-items: center;">
				<view class="leftIcon"></view>
				<Sub-title label="活动简介" />
			</view>

			<u-parse :content="detail.message" />
			<view class="" style="display: flex;align-items: center;">
				<view class="leftIcon"></view>
				<Sub-title label="活动详情" />
			</view>
			<view class="" v-if="detail.video" style="margin: 0 auto;text-align: center;">
				<video :src="baseUrl+detail.video"  class="image"></video>
			</view>
			<!-- <view class="card-item" v-if="detail.image">
				<img :src="$imageOss(detail.image)" alt="" mode="widthFix">
			</view> -->
			<view class="detail_content" >
				<view class="" v-html="detail.content" />
			</view>
			<view class="" style="display: flex;align-items: center;">
				<view class="leftIcon"></view>
				<Sub-title label="评论" />
			</view>
			<remark :page="page" @lastPage="lastPage" v-if="detail.id" :typeId="detail.id" :type="4" :adminId="detail.admin_id" />
		</view>
		<view class="bott">
			<Foot :comment="detail.count" :like="detail.like" :collect="detail.collect" :type="4"
				:path="'/pages/home/activityDetail'" :is_like="detail.is_like" :is_collect="detail.is_collect"
				:is_id="detail.id" @like="handleLike"></Foot>

			<view class="button" @tap.stop="handle" v-if="detail.test == '我要报名'"> {{detail.test}}</view>
			<view class="button" style="background: #A9A9AA;" v-else> {{detail.test}}</view>
		</view>
	</view>
</template>

<script>
	import Navbar from "@/components/Navbar/index";
	import Foot from "@/components/footer/index";
	import config from "@/request/baseUrl.js";
	import remark from "@/components/remark/index";
	import {
		actDetail
	} from "@/request/homeApi.js";
	export default {
		components: {
			Navbar,
			Foot,
			remark
		},
		data() {
			return {
				baseUrl: config.baseUrl,
				detail: {},
				page:1,
				last_page:1
			};
		},
		onLoad(e) {
			this.getDetails(e.id);
		},
		onReachBottom() {
			let that = this
			if (that.page < that.last_page) {
				that.page = that.page + 1
			}
		},
		computed: {


		},
		// 监听页面滚动
		onPageScroll(scroll) {
			uni.$emit("onPageScroll", scroll.scrollTop);
		},
		methods: {
			lastPage(e){
				this.last_page = e
			},
			// 点赞/收藏
			handleLike(v) {
				this.getDetails(v)
			},
			Jump(url) {
				uni.navigateTo({
					url: url
				})
			},
			// 预览图片
			preImage() {
				console.log(this.detail,'this.detail.cover_img')
				uni.previewImage({
					urls: [this.detail.cover_img],
				});
			},
			// 点击拨号
			callPhone() {
				uni.makePhoneCall({
					phoneNumber: this.detail.telphone,
				});
			},

			// 报名
			handle(e) {
				if (this.detail.registered == this.detail.limit) {
					uni.showToast({
						title: '报名已达上限',
						icon: "none",
					});
					return;
				}
				uni.navigateTo({
					url: `/pages/home/applyDetails?type=active&nickname=${this.detail.title}&id=${this.detail.id}`,
				});
			},

			// 获取详情
			getDetails(id) {
				actDetail({
					id
				}).then((res) => {
					if (res.code == 200) {
						this.detail = res.data;
					} else {
						uni.showToast({
							title: res.msg,
							duration: 1500,
							icon: 'none',
						})
					}
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	.page {
		.leftIcon {
			width: 6rpx;
			height: 30rpx;
			margin-right: 10rpx;
			background: #47578E;
		}
		.detail_content{
			img{
				width: 98% !important;
			}
		}
		.bott {
			position: fixed;
			bottom: 0;
			left: 0;
			height: 110rpx;
			background: #fff;
			width: 100%;
			display: flex;
			align-items: center;
			padding: 30rpx 40rpx 40rpx;
			justify-content: space-between;
			box-shadow: 0 0 10rpx rgba(228, 228, 228, 0.5);
			box-sizing: border-box;
			z-index: 100;

			.button {
				width: 35%;
				height: 70rpx;
				padding: 0 28rpx;
				box-sizing: border-box;
				margin-left: 20rpx;
				text-align: center;
				line-height: 70rpx;
				color: #fff;
				font-size: 28rpx;
				background-color: $active-color;
				border-radius: 10rpx;
			}
		}

		.body {
			width: 100%;
			padding: 20rpx 24rpx;
			padding-bottom: 120rpx;
			min-height: 100rpx;
			box-sizing: border-box;
			background-color: #ffffff;
			margin-top: -14rpx;

			.base {
				padding-bottom: 10rpx;
				border-bottom: 2rpx solid #D9D9D9;

				.box {
					display: flex;
					align-items: center;
					justify-content: space-between;
				}
			}

			.card-item {
				width: 100%;
				margin: 10rpx 0;
				box-sizing: border-box;
				text-align: center;

				.image {
					width: 100%;
					height: 240rpx;
				}
			}
		}
	}
</style>